<template>
	<view class="mess">
		<view class="mess-list">
		
			
			<view class="mess-item" v-for="(item,index) in weetlist">
				<view class="mess-user">
					<view style=" position: relative;">
						<image :src="item.user.avatar" class="user-img"></image>
						<view class="user-img2"  v-if="item.user.level==3">
							<image src="/static/images/luzhuan.png" style="width: 9px;height: 9px;"></image>
						</view>
						<view class="user-img2" v-if="item.user.level==2">
							<image src="/static/images/fengzuan.png" style="width: 9px;height: 9px;"></image>
						</view>
					</view>
					<view class="mess-name">{{item.user.nickname}}</view>
					<view class="mess-time">{{item.create_time}}</view>
				</view>
				<view>
					<view class="mess-info">
						
						<view v-if="item.from==0">
							<text style="color: #333333;font-weight: bold;" ></text><text style="color: #426FB6;font-weight: bold;"></text>{{item.message}}
						</view>
						
						<view  v-else>
							<text style="color: #333333;font-weight: bold;" >回复</text>
							<text style="color: #426FB6;font-weight: bold;">{{item.from_user.nickname}}：</text>{{item.message}}
						</view>
					</view>
					<view class="mess-book">
						<image :src="item.moments.atlas[0]"></image>
						<view class="mess-right" style="width: 80%;display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
word-break: break-all;overflow: hidden;">
							<view style="font-size: 15px;color: #333333;font-weight: bold;margin-bottom: 6px;">{{item.moments.content}}</view>
						</view>
					</view>
				</view>
			</view>
			<uni-load-more
			:status="loadStatus"
			></uni-load-more>
		</view>
	</view>
</template>

<script>
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
	
	
	export default {
		data() {
			return {
				loadStatus: 'more',
				page: 1,
				weetlist: []
			}
		},
		onLoad(){
			this.gettWeetList();
			this.getserve()
		},
		components: {uniLoadMore},
		onReachBottom () {
			if (this.loadStatus === 'more') {
				this.gettWeetList()
			}
		},
		methods: {
			//推文列表
			gettWeetList(type) {
			const params = {
				status: this.status,
				page: this.page
			}
				
				this.loadStatus = 'loading'
				this.$http.get('/moments/news',{params: params}).then((response) => {
					const res = response.data;
					console.log(res)
					if (res.code==0) {
						if (this.page > res.data.last_page) {
							// 没有数据了
							this.loadStatus = 'noMore'
						} else {
							// 未加载完毕
							this.loadStatus = 'more'
							this.page ++
						}
					

						if(type){
							this.weetlist = res.data.data;
							
							
						}else{
							this.weetlist = [...this.weetlist, ...res.data.data];
							// uni.setStorageSync('notice_md5',res.msg);
						}
						this.filter = false
					} else {
					   this.filter = false
					}
				})
			},
			getserve(){
				this.$http.get("/moments/news").then(response => {
				   let res = response.data
					  if(res.code==0){
					   uni.setStorageSync('notice_md5',res.msg);
					  }
								
				 });
			}
		}
	}
</script>

<style scoped>
	.mess{
		height: 100%;
		position: absolute;
		background-color: #fff;
		width: 100%;
		padding: 0 17px;
	}
.mess-list{
	display: flex;
	flex-direction: column;
	position: relative;
}
	
	.mess-item{
		border-bottom: 1px solid #F5F5F5;
		padding: 14px 0;
	}
.mess-user{
	display: flex;
	    flex-direction: row;
	    align-items: center;
	    justify-content: space-between;
}
.user-img{
	width: 30px;
	height: 30px;
	border-radius: 50%;
}

.mess-name{
	    flex: 1;
		font-size: 15px;
		color: #426FB6;
		font-weight: bold;
		    margin-left: 10px;
}
.mess-time{
	color: #999999;
	font-size: 12px;
}
.mess-info{
	font-size: 14px;
	color: #666666;
	margin-left: 76upx;
}
.mess-book{
	display: flex;
	flex-direction: row;
	    align-items: center;
		height: 78px;
		background-color: #F5F5F5;
		padding: 0 10px;
		border-radius: 5px;
		margin-left: 76upx;
}
.mess-book image{
	width: 59px;
	height: 59px;
	margin-right: 12px;
}
.user-img2{
	width: 20px;
	    height: 20px;
	    border-style: solid;
	    border-color: #fff;
	    border-radius: 50%;
	    position: absolute;
	    right: -10px;
	    bottom: 2px;
	    background-color: #3E3400;
}
.user-img2 image{
	    width: 9px;
	    height: 9px;
	    position: absolute;
	    /* right: 5px; */
	    text-align: 0;
	    /* top: 0; */
	    /* left: 0; */
	    /* bottom: 0; */
	    left: 2.5px;
	    top: 3px;
}
</style>
